import request from '@/utils/request'

export function getVisitData(data) {
  return request({
    url: '/crm/visit/getResPageData',
    method: 'post',
    data
  })
}

export function getCrmFileInfo(data) {
  return request({
    url: '/crm/crmFileInfo/getResPageCOSData',
    method: 'post',
    data
  })
}

export function deleteFileById(data) {
  return request({
    url: '/crm/crmFileInfo/deleteFileById',
    method: 'post',
    data
  })
}

export function deleteFileByIds(data) {
  return request({
    url: '/crm/crmFileInfo/deleteFileByIds',
    method: 'post',
    data
  })
}

export function deleteFile(data) {
  return request({
    url: '/crm/crmFileInfo/deleteFileByIds',
    method: 'post',
    data
  })
}

export function printByHeaderId(url, id) {
  return request({
    url: '/crm/visit/printById',
    method: 'post',
    data: { id }
  })
}

export function printPDF(path, data) {
  return request({
    url: '/' + path + '/printPDF',
    method: 'post',
    data
  })
}

export function exportExcel(path, data) {
  const exportUrl = '/' + path + '/exportExcel'
  var temp = document.createElement('form')
  temp.action = exportUrl
  temp.method = 'POST'
  temp.style.display = 'none'
  for (var x in data.queryParam) {
    var opt = document.createElement('textarea')
    opt.name = x
    opt.value = data.queryParam[x] || null
    temp.appendChild(opt)
  }
  document.body.appendChild(temp)
  temp.submit()
  return temp
}
